<?php
require 'isok.php';
require 'dbcon.php';

//查询文章数
$sql="select * from posts where status!='trashed'";
$result=$db->query($sql);
$num=$result->num_rows;

//查询草稿有多少篇
$sql="select * from posts where status='drafted'";
$result=$db->query($sql);
$num1=$result->num_rows;

 //查询分类
$sql="select * from categories ";
$result=$db->query($sql);
$num2=$result->num_rows;

//查询评论
$sql="select * from comments where status!='trashed'";
$result=$db->query($sql);
$num3=$result->num_rows;

//待审核
$sql="select * from comments where status!='held'";
$result=$db->query($sql);
$num4=$result->num_rows;

?>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>Dashboard &laquo; Admin</title>
  <link rel="stylesheet" href="css/bootstrap.css">
  <link rel="stylesheet" href="font-awesome-4.7.0/css/font-awesome.css">
  <link rel="stylesheet" href="css/nprogress.css">
  <link rel="stylesheet" href="css/admin.css">
  <script src="js/nprogress.js"></script>
</head>
<body>
  <script>NProgress.start()</script>

  <div class="main">
    <nav class="navbar">
      <button class="btn btn-default navbar-btn fa fa-bars"></button>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="profile.php"><i class="fa fa-user"></i>个人中心</a></li>
        <li><a href="logout.php"><i class="fa fa-sign-out"></i>退出</a></li>
      </ul>
    </nav>
    <div class="container-fluid">
      <div class="jumbotron text-center">
        <h1>One Belt, One Road</h1>
        <p>Thoughts, stories and ideas.</p>
        <p><a class="btn btn-primary btn-lg" href="ispost-add.php" role="button">写文章</a></p>
      </div>
      <div class="row">
        <div class="col-md-4">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title">站点内容统计：</h3>
            </div>
            <ul class="list-group">
              <li class="list-group-item"><strong><?php echo $num; ?></strong>篇文章（<strong><?php echo $num1; ?></strong>篇草稿）</li>
              <li class="list-group-item"><strong><?php echo $num2; ?></strong>个分类</li>
              <li class="list-group-item"><strong><?php echo $num3; ?></strong>条评论（<strong><?php echo $num4; ?></strong>条待审核）</li>
            </ul>
          </div>
        </div>
        <div class="col-md-4"></div>
        <div class="col-md-4"></div>
      </div>
    </div>
  </div>

  <div class="aside">
    <div class="profile">
        <img class="avatar" src="<?php echo $userinfo['avatar']?>">
        <h3 class="name"><?php echo $userinfo['nickname']?></h3>
    </div>
    <ul class="nav">
      <li class="active">
          <a href="index.php"><i class="fa fa-dashboard"></i>仪表盘</a>
      </li>
      <li>
        <a href="#menu-posts" class="collapsed" data-toggle="collapse">
          <i class="fa fa-thumb-tack"></i>文章<i class="fa fa-angle-right"></i>
        </a>
        <ul id="menu-posts" class="collapse">
          <li><a href="isposts.php">所有文章</a></li>
          <li><a href="ispost-add.php">写文章</a></li>
          <li><a href="iscategories.php">分类目录</a></li>
        </ul>
      </li>
      <li>
        <a href="iscomments.php"><i class="fa fa-comments"></i>评论</a>
      </li>
      <li>
        <a href="isusers.php"><i class="fa fa-users"></i>用户</a>
      </li>
      <li>
        <a href="#menu-settings" class="collapsed" data-toggle="collapse">
          <i class="fa fa-cogs"></i>设置<i class="fa fa-angle-right"></i>
        </a>
        <ul id="menu-settings" class="collapse">
          <li><a href="isnav-menus.php">导航菜单</a></li>
          <li><a href="slides.php">图片轮播</a></li>
          <li><a href="issettings.php">网站设置</a></li>
        </ul>
      </li>
    </ul>
  </div>

  <script src="js/jquery.js"></script>
  <script src="js/bootstrap.js"></script>
  <script>NProgress.done()</script>
</body>
</html>
